/*
 * @Description: 钩子
 * @Author: HuiSir<https://gitee.com/huisir001>
 * @Date: 2025-07-10 17:34:22
 * @LastEditTime: 2025-07-10 17:57:57
 */
import {
  App,
  ComponentInternalInstance,
  getCurrentInstance,
  ComponentPublicInstance,
} from "vue";

// 追加新字段
export interface GlobalInstance extends ComponentPublicInstance {
  $getIcons: () => string[];
}

export function useCurrentInstance(app?: App) {
  const instance = getCurrentInstance() as ComponentInternalInstance;
  const globalProperties = (app || instance.appContext).config
    .globalProperties as GlobalInstance;
  return {
    proxy: app
      ? globalProperties
      : ((instance ? instance.proxy! : {}) as GlobalInstance),
    globalProperties: app
      ? app.config.globalProperties
      : ((instance
          ? instance.appContext.config.globalProperties
          : {}) as GlobalInstance),
  };
}
